#pragma once

#include "ShaderData.h"
class Model;

struct RayTriangleIntersection
{
	DirectX::XMFLOAT3 rayOrigin;
	DirectX::XMFLOAT3 rayDirection;
	DirectX::XMFLOAT3 trianglePoints[3];
	DirectX::XMFLOAT3 tuv;
	DirectX::XMFLOAT3 intersectionPoint;
	bool intersecting;
};

class TriangleAccessor
{
public:
	TriangleAccessor(Model* modelAccessed, SimpleVertex* pointA, SimpleVertex* pointB, SimpleVertex* pointC);
	Model* GetModelAccessed(void);
	DirectX::XMFLOAT3* GetRealPositions(void);
	DirectX::XMFLOAT3 GetLowerBounds(void) const;
	DirectX::XMFLOAT3 GetUpperBounds(void) const;
	DirectX::XMFLOAT3 GetCentroid(void) const;
	void HighLight(bool highlight);
	RayTriangleIntersection IntersectWithRay(const DirectX::XMFLOAT3& rayPoint, const DirectX::XMFLOAT3& rayVector);
private:
	SimpleVertex* m_vertices[3];
	DirectX::XMFLOAT3 m_realPositions[3];
	DirectX::XMFLOAT3 m_lowerBounds;
	DirectX::XMFLOAT3 m_upperBounds;
	DirectX::XMFLOAT3 m_centroid;
	Model* m_modelAccessed;
};